<template>
  <div class="app-container">
    <el-form ref="form" :model="form" label-width="150px" style="margin-left: 50px;margin-top: 30px;width: 700px">
      <el-form-item label="请假类型" prop="type">
        <el-select v-model="form.type" placeholder="请选择请假类型">
          <el-option
            v-for="dict in dict.type.ask_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="开始时间" prop="leaveDate">
        <el-date-picker clearable
            v-model="form.leaveDate"
            type="date"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择开始时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="结束时间" prop="returnDate">
        <el-date-picker clearable
            v-model="form.returnDate"
            type="date"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择结束时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="申请理由" prop="reasons">
        <el-input
          type="textarea"
          :autosize="{ minRows: 2, maxRows: 5}"
          placeholder="请输入申请理由"
          v-model="form.reasons">
        </el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">申请</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>

  </div>
</template>

<script>
import {  addAskLeave } from "@/api/system/askLeave";

export default {
  name: "Evection",
  dicts: ['ask_leave','ask_type'],
  data() {
    return {
      form: {
        cost:0
      }
    }
  },

  created() {
    // this.getList();
  },
  methods: {
    onSubmit() {
      addAskLeave(this.form).then(response => {
        this.$modal.msgSuccess("新增成功");
        this.reset();
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        startDate: null,
        endDate: null,
        target: null,
        objective: null,
        cost: null
      };
      this.resetForm("form");
    },

  }
};
</script>
